using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FrameWork;

public class TreeOrOreAgent : MonoBehaviour, IAttack
{
    [Header("基础信息")]
    [SerializeField] private GameObject prefab;
    [SerializeField] private float health;
    public void Attack(float damage)
    {
        health -= damage;
        if (health <= 0)
            Death();
    }

    private void Death()
    {
        // 生成矿石
        Instantiate(prefab, transform.position, transform.rotation);
        // 放回对象池
        ObjectPool.Instance.Replace(this.gameObject.name, this.gameObject);
    }
}
